package cn.iocoder.yudao.module.project.dal.mysql.constructionunit;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.project.dal.dataobject.constructionunit.ProjectConstructionunitDO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

@Mapper
public interface ProjectConstructionUnitMapper extends BaseMapperX<ProjectConstructionunitDO> {

    default List<ProjectConstructionunitDO> selectListByInfoId(Long projectId) {
        return selectList(ProjectConstructionunitDO::getInfoId, projectId);
    }

    default void deleteByInfoIdAndConstructionUnitIdId(Long projectId, Collection<Long> constructionUnitIds) {
        delete(new LambdaQueryWrapperX<ProjectConstructionunitDO>()
                .eq(ProjectConstructionunitDO::getInfoId, projectId)
                .in(ProjectConstructionunitDO::getConstructionUnitId, constructionUnitIds));
    }

    default List<ProjectConstructionunitDO> selectListByConstructionUnitIds(Collection<Long> constructionUnitIds) {
        return selectList(ProjectConstructionunitDO::getConstructionUnitId, constructionUnitIds);
    }

    default void deleteByInfoId(Long projectId) {
        delete(Wrappers.lambdaUpdate(ProjectConstructionunitDO.class).eq(ProjectConstructionunitDO::getInfoId, projectId));
    }
}
